popup
Type
command
Summary
Displays a popup menu whose menu items are either lines in a button or buttons in a stack.
Syntax
popup {<stack> | <button>} [at <location>]
Description
Use the popup command to display a contextual menu.
Use the popup command in a mouseDown handler to display the menu.
The popup menu appears with its top left corner at the location. If no location is specified, the menu's top left corner is at the mouse location. While the popup menu is displayed, the handler pauses.
Choosing a menu item from the popup menu sends a menuPick message to the button (for a button menu) or a mouseUp message to the clicked control in the stack (for a stack menu). The button or stack menu handles the menu choice.
If you use a button to hold the contents of the menu, the contents of the button's menuItem is displayed in the popup.
Important: If you use a button to hold the contents of the menu, the following properties must be set:
- style must be set to "menu"
- menuMode must be set to "popup"
- visible may be set to either true or false.
Important: You must escape reserved characters in the button's menuItem. These include:
&
(To display the string "A&B" in the popup menu, use "A&&B")\
(To display the string "A\B" in the popup menu, use "A\B")/
(To display the string "A/B" in the popup menu, use "A//B")
Important: The menuMouseButton of a button used with the popup command must be set to zero. Setting it to any other value may result in unexpected behavior when the menu is used. To control which mouse buttons may be used to access the menu, use the mouse button parameter of the mouseDown message, as described above.
Parameters
Name | Type | Description |
---|---|---|
stack | Any stack reference. The stack's first card contains a button for each menu item in the popup menu. | |
button | A reference to a button on the current card | |
location | A point or expression that evaluates to a point. Two integers separated by a comma. |
Examples
popup button "Contextual Menu"
popup stack "Button Properties"
on mouseDown theButton
-- pop up the menu on right-click or control-click
if theButton is 3 then popup stack "Lookup Options"
else pass mouseDown
end mouseDown
Related
glossary: menu item, popup menu, message
keyword: button, menuItem, popup
message: menuPick, mouseDown, mouseDown, mouseUp
property: style, toolTip, menuMode, visible, menuMouseButton
command: pulldown
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
Platforms
desktop
server